package com.example.demo.controller.AuthorControl;

import com.example.demo.entity.BackResponseEntity;
import com.example.demo.entity.requestJson.*;
import com.example.demo.entity.responseJson.ABookBaseInfoRes;
import com.example.demo.entity.responseJson.AQueryBookRes;
import com.example.demo.entity.responseJson.ListResult;
import com.example.demo.service.AuthorCreationService;
import com.example.demo.service.AuthorPostService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author : 杨丽辉
 * @date : 2021/3/3 13:52
 * @description:
 */
@RestController
@RequestMapping("/author/creation")
@Api(value = "创作中心接口", tags = "创作中心接口")
public class AuthorCreationController {
    @Autowired
    private AuthorCreationService authorCreationService;
    @Autowired
    private AuthorPostService authorPostService;

    @ApiOperation(value = "新作品开坑填写书本信息接口", notes = "")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )

    @PostMapping("/insertbook")
    public BackResponseEntity<Object> insertInformation(@RequestBody ABookInformationReq aBookInformationReq) {
        return authorCreationService.insertInformation(aBookInformationReq);
    }

    @ApiOperation(value = "编辑书籍信息接口", notes = "")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )

    @PostMapping("/updatebook")
    public BackResponseEntity<Object> updateinformation(@RequestBody AUpdateBookInfoReq aUpdateBookInfoReq) {
        return authorCreationService.updateInformation(aUpdateBookInfoReq);
    }

    @ApiOperation(value = "删除书籍接口", notes = "")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )

    @DeleteMapping("/deletebooks")
    public BackResponseEntity<Object> deleteBook(@RequestBody DeleteReq deleteReq) {
        return authorCreationService.deleteInformation(deleteReq);
    }

    @ApiOperation(value = "查询书籍详情接口", notes = "传books_id")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )

    @GetMapping("/querymoreinfo")
    public BackResponseEntity<AQueryBookRes> queryMoreBookInfo(DeleteReq deleteReq) {
        return authorCreationService.queryMoreBookInfo(deleteReq);
    }

    @ApiOperation(value = "查询书籍基本信息接口", notes = "传author_id")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )

    @GetMapping("/querybaseinfo")
    public BackResponseEntity<ListResult<List<ABookBaseInfoRes>>> queryBaseBookInfo(DeleteReq deleteReq) {
        return authorCreationService.queryBaseBookInfo(deleteReq);
    }

    @ApiOperation(value = "发布新帖子接口", notes = "")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )

    @PostMapping("/insertpost")
    public BackResponseEntity<Object>insertPost(@RequestBody InsertPostReq insertPostReq){
        return authorPostService.insertPost(insertPostReq);
    }

    @ApiOperation(value = "编辑帖子信息接口", notes = "")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )

    @PostMapping("/updatepost")
    public BackResponseEntity<Object> updatePost(@RequestBody UpdatePostReq updatePostReq){
        return authorPostService.updatePost(updatePostReq);
    }

    @ApiOperation(value = "删除帖子接口", notes = "传postId")
    @ApiOperationSupport(author = "杨")
    @ApiResponses(
            @ApiResponse(code = 200, message = "处理成功")
    )
    @DeleteMapping("/deletepost")
    public BackResponseEntity<Object> deletePost(DeleteReq deleteReq){
        return authorPostService.deletePost(deleteReq);
    }
}
